
/** 
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package com.tompai.datagather;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;

import com.tompai.datagather.tencent.TenNewsCrawler;
import com.tompai.datagather.tencent.TenNewsTask;

/**
* @desc: datagather-tools
* @name: TimeTaskCrawler.java
* @author: tompai
* @createTime: 2018年5月2日 上午10:43:20
* @history:
* @version: v1.0
*/

public class TencentNewsCrawlerDemo {

	private static final Logger logger = Logger.getLogger(TenNewsCrawler.class);
	/**
	* @author: tompai
	* @createTime: 2018年5月2日 上午10:43:20
	* @history:
	* @param args void
	*/

	public static void main(String[] args) {
		//TODO Auto-generated method stub 
        //==============//
		//String testUrl="http://news.qq.com/articleList/rolls/";
		
        Runnable runnable = new Runnable() {
            public void run() {
            	logger.info("TimerTask is will begain...");
                TenNewsTask  currentTask = new TenNewsTask(); 
                currentTask.run();
            }
        };
        ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
        // 参数：1、任务体 2、首次执行的延时时间  3、任务执行间隔  4、间隔时间单位
        service.scheduleAtFixedRate(runnable, 0, 1*60, TimeUnit.SECONDS);
	}
}

